﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}
<style type="text/css">
    .ui-jqgrid .table-bordered th {
        height: 52px !important;
    }
</style>
<script type="text/javascript">
    var number = 1;
    $(function () {
        initControl();
        gridList();
    });
    function initControl() {
        $('select').bindSelect();
        $("#radio11").attr("checked", true);
    }
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/BOM/Product/GetStampingContrastJson",
            height: $(window).height() - 134,
            colModel: [
                { label: '父代号1', name: 'FDH1', width: 170, align: 'center' },
                { label: '父代号2', name: 'FDH2', width: 170, align: 'center' },
                { label: '子代号', name: 'ZDH', width: 170, align: 'left' },
                { label: '名称', name: 'ZMC', width: 240, align: 'left' },
                { label: '装配<br />路线', name: 'AssembleLine', width: 40, align: 'center', sortable: false },
                { label: '制造路线', name: 'MakeLine', width: 180, align: 'left', sortable: false },
                { label: '数量1', name: 'SL1', width: 60, align: 'right' },
                { label: '数量2', name: 'SL2', width: 60, align: 'right' },
                { label: '备注', name: '', width: 10, align: 'left' }
            ],
            pager: "#gridPager",
            sortname: 'ZDH asc',
            viewrecords: true,
            rownumWidth: 40
        });
        $gridList.jqGrid('setLabel', 0, '序号', 'rowNumberHeaderStyle');
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { number: $("#txt_keyword").val(), type: $("input[name='category']:checked").val() },
                page: 1,
            }).trigger('reloadGrid');
        });
    }
    var subwindow;
    function btn_show_fdh() {
        subwindow = layer.open({
            type: 1,
            title: '',
            offset: '100px',
            skin: 'layui-layer-rim',
            area: ['500px', '155px'], //宽高
            closeBtn: 0, //不显示关闭按钮
            content: '<div class="" style="background-color: rgb(26, 188, 156);height: 32px;line-height: 32px;font-size: 14px;font-weight: 900;color: #fff;padding-left: 15px;">请选择进行差异对比的产品：</div>\
                <div style="padding: 20px 0 15px 15px;" class="line-table input-width-185">\
                <div class="btn-group" style="margin-top:-9px;">\
                父代号1<br /><input id="txtNumber1" name="txtNumber1" type="text" class="form-control" disabled="disabled" />\
            </div>\
            <div class="btn-group" style="margin-top:9px;">\
                <a id="" class="btn btn-primary center-block btn-1" onclick="btn_choose_parts(1)"><span class="glyphicon glyphicon-search"></span> </a> &nbsp;\
        </div>\
        <div class="btn-group" style="margin-top:-9px;">\
            父代号2<br /><input id="txtNumber2" name="txtNumber2" type="text" class="form-control" disabled="disabled" />\
        </div>\
        <div class="btn-group" style="margin-top:9px;">\
            <a id="" class="btn btn-primary center-block btn-1" onclick="btn_choose_parts(2)"><span class="glyphicon glyphicon-search"></span> </a> &nbsp;\
        </div>\
        </div>\
        <div style="text-align:center;">\
            <div class="btn-group" style="">\
                <a id="btn_ok" class="btn btn-primary center-block" onclick="btn_ok()"><span class="glyphicon glyphicon-ok"></span> 确认</a>\
            </div>\
            <div class="btn-group" style="margin-left:20px;">\
                <a id="btn_cancel" class="btn btn-danger center-block" onclick="btn_cancel()"><span class="glyphicon glyphicon-remove"></span> 取消</a>\
            </div>\
       </div>'
        });
    }
    function btn_ok() {
        var number1 = $.trim($("#txtNumber1").val());
        var number2 = $.trim($("#txtNumber2").val());
        if (number1 == '' || number2 == '') {
            $.modalAlert('必须选择父代号1和父代号2。', 'warning');
        } else if (number1 == number2) {
            $.modalAlert('父代号1和父代号2不可相同。', 'warning');
        }else {
            layer.close(subwindow);
            $.loading(true, "差异对比进行中......");
            $.get("/BOM/Product/SetStampingContrastResult", { number1: number1, number2: number2 },
                function (data) {
                    $.reload();
                });
        }
    }
    function btn_cancel() {
        $("#txtNumber1").val("");
        $("#txtNumber2").val("");
        layer.close(subwindow);
    }
    function btn_choose_parts(number_type) {
        number = number_type;
        var title = '选择差异对比产品' + number;
        var url = '/BOM/Product/ChooseParts';
        $.detailOpenTop({
            id: "Detail",
            title: title,
            url: url,
            width: 900,
            height: 540
        });
    }
    function do_choose_parts(parts_id) {
        $.detailCloseTop();
        if (number == 1) {
            $('#txtNumber1').val(parts_id);
        } else if (number == 2) {
            $('#txtNumber2').val(parts_id);
        }
    }
</script>
<div id="layout" style="height: 100%; width: 100%;">
    <form id="form1">
        <div style="padding: 12px 0 5px 0; padding-left: 15px; border-bottom: 1px solid #ccc; " class="line-table input-width-185">
            <div class="btn-group" style="">
                <input id="radio11" class="category" name="category" type="radio" value="所有件" /><label for="radio11" class="suffix">所有件</label> &nbsp;
                <input id="radio12" class="category" name="category" type="radio" value="差别件" /><label for="radio12" class="suffix">差别件</label> &nbsp;
                <input id="radio13" class="category" name="category" type="radio" value="相同件" /><label for="radio13" class="suffix">相同件</label> &nbsp;
            </div>
            <div class="btn-group" style="margin-top:-9px;">
                子代号<br /><input id="txt_keyword" name="txt_keyword" type="text" class="form-control input-width-105" /> &nbsp;
            </div>
            <div class="btn-group" style="">
                <a id="btn_search" class="btn btn-primary center-block" onclick=""><span class="glyphicon glyphicon-search"></span> 搜索</a>
            </div>
            <div class="btn-group" style="float:right;">
                <a id="" class="btn btn-primary center-block" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span> 刷新</a>
                <a id="" class="btn btn-primary center-block" onclick="btn_show_fdh()"><span class="glyphicon glyphicon-retweet"></span> 对比</a>
                <a id="" class="btn btn-primary center-block disabled" onclick=""><span class="glyphicon glyphicon-download"></span> 导出</a>
            </div>
        </div>
    </form>
    <div style="">
        <table id="gridList"></table>
        <div id="gridPager"></div>
    </div>
</div>

